package org.edu.modules.noderes.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.edu.modules.noderes.dto.NodeResDto;
import org.edu.modules.noderes.entity.VeCuzNodeRes;
import org.edu.modules.noderes.mapper.VeCuzNodeResMapper;
import org.edu.modules.noderes.service.IVeCuzNodeResService;
import org.edu.modules.resource.entity.VeResCatalogResource;
import org.edu.modules.resource.entity.VeResResource;
import org.edu.modules.resource.file.entity.VeFileFiles;
import org.edu.modules.resource.file.service.IVeFileFilesService;
import org.edu.modules.resource.service.IVeResCatalogResourceService;
import org.edu.modules.resource.service.IVeResResourceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class VeCuzNodeResServiceImpl
        extends ServiceImpl<VeCuzNodeResMapper, VeCuzNodeRes>
        implements IVeCuzNodeResService
{
    @Autowired
    IVeResResourceService veResResourceService;
    @Autowired
    IVeResCatalogResourceService veResCatalogResourceService;
    @Autowired
    VeCuzNodeResMapper veCuzNodeResMapper;
    @Autowired
    IVeFileFilesService veFileFilesService;

    public Boolean save(VeCuzNodeRes veCuzNodeRes, VeResResource veResResource, VeResCatalogResource veResCatalogResource)
    {
        this.veResCatalogResourceService.save(veResCatalogResource);

        return Boolean.valueOf(this.veCuzNodeResMapper.insert(veCuzNodeRes) > 0);
    }

    public VeCuzNodeRes getByNodeId(int nodeId, int courseId)
    {
        return this.veCuzNodeResMapper.getByNodeId(nodeId, courseId);
    }

    public void selectResById(Integer nodeid) {}

    public NodeResDto selectNodeRes(Integer nodeid)
    {
        Map<String, Object> params = new HashMap();
        params.put("nodeid", nodeid);
        NodeResDto nodeResDto = new NodeResDto();
        List<VeFileFiles> veFileFiles = this.veFileFilesService.selectNodeRes(params);
        String[] cataid = this.veResCatalogResourceService.selectCataId(params);
        String[] cataName = this.veResCatalogResourceService.selectCataId(params);
        nodeResDto.setCataid(cataid);
        nodeResDto.setCataName(cataName);
        nodeResDto.setVeFileFilesList(veFileFiles);
        return nodeResDto;
    }
}
